import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router);
const Index = resolve => require(['@/views/Index.vue'], resolve)
const Category = resolve => require(['@/views/Category.vue'], resolve)
const CategoryMain = resolve => require(['@/components/category/main.vue'], resolve)
const Car = resolve => require(['@/views/Car.vue'],resolve)
const User = resolve => require(['@/views/User.vue'], resolve)
const Detail = resolve => require(['@/views/Detail.vue'], resolve)
const Search = resolve => require(['@/views/Search.vue'], resolve)
const Pay = resolve => require(['@/components/car/pay/pay.vue'], resolve)
const Login = resolve => require(['@/views/login.vue'], resolve)

// 我的资产
const Asset = resolve => require(['@/views/Asset.vue'], resolve)
// 提现奖励金
const CashReward = resolve => require(['@/views/CashReward.vue'], resolve)
// 收货地址
const Address = resolve => require(['@/views/Address.vue'], resolve)
// 订单
const Orders = resolve => require(['@/views/Orders.vue'], resolve)

export default new Router({
  routes: [{
      path: '/home',
      name: '首页',
      component: Index
    }, {
      path: '/category',
      name: '分类页',
      redirect: '/category/all',
      component: Category,
      children: [{
        path: '/category/:tab',
        component:CategoryMain
      }]
    }, {
      path: '/car',
      name: '购物车页',
      component: Car
    }, {
      path: '/car/pay',
      name: '支付页',
      component: Pay
    },
    {
      path: '/user',
      name: '个人中心',
      component: User,
      meta: {
           requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录才能进入的
       },
    }, {
      path: '/goodsDetails',
      name: '详情页',
      component: Detail
    }, {
      path: '/search',
      name: '搜索页',
      component: Search
    },{
      path: '/login',
      name: '登录页',
      component: Login
    },{
      path: '/asset',
      name: '我的资产',
      component: Asset,
    },{
      path: '/cash-reward',
      name: '提现奖励金',
      component: CashReward,
    },{
      path: '/address',
      name: '收货地址',
      component: Address,
    },{
      path: '/orders',
      name: '订单',
      component: Orders,
    }
  ]
})
